package com.qq.bean;

import org.springframework.beans.factory.config.DestructionAwareBeanPostProcessor;
import org.springframework.stereotype.Component;

/**
 * @author Bob
 */
public class CustomDestroyProcessor implements DestructionAwareBeanPostProcessor {

    // 在 Bean 销毁前拦截
    @Override
    public void postProcessBeforeDestruction(Object bean, String beanName) {
        if (bean instanceof User) {
            System.out.println("拦截销毁逻辑，BeanName: " + beanName);
            // 这里可以动态修改或增强销毁行为
        }
    }

    // 决定是否需要跳过 Spring 的标准销毁流程
    @Override
    public boolean requiresDestruction(Object bean) {
        return true; // 默认不跳过
    }
}